package com.medical.doctor.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.medical.doctor.controller.vo.AuditVo;
import com.medical.doctor.controller.vo.DoctorInquiryVo;
import com.medical.doctor.entity.DoctorLabelEntity;
import com.medical.doctor.entity.PatientPatientEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.Query;

import com.medical.doctor.dao.DoctorMessageDao;
import com.medical.doctor.entity.DoctorMessageEntity;
import com.medical.doctor.service.DoctorMessageService;


@Service("doctorMessageService")
public class DoctorMessageServiceImpl extends ServiceImpl<DoctorMessageDao, DoctorMessageEntity> implements DoctorMessageService {

    @Autowired
    private DoctorMessageDao doctorMessageDao;

   

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<DoctorMessageEntity> page = this.page(
                new Query<DoctorMessageEntity>().getPage(params),
                new QueryWrapper<DoctorMessageEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public IPage<AuditVo> audit(Integer page, Integer size, AuditVo data) {
        Page<AuditVo> auditVoPage = new Page<>(page, size);
        return doctorMessageDao.audit(auditVoPage,data);
    }

    @Override
    public String inquiry(Integer inquiry,Integer doctorId) {
        doctorMessageDao.inquiry(inquiry,doctorId);

        return "1";
    }
    @Override
    public List<DoctorInquiryVo> inquiryList(DoctorInquiryVo inquiryVo) {
        return doctorMessageDao.inquiryList(inquiryVo);
    }



    @Override
    public AuditVo registration(Integer doctorId) {
        return doctorMessageDao.findByDoctorId(doctorId);
    }

    @Override
    public String status(Integer doctorId, String status, String reason) {
            doctorMessageDao.status(doctorId,status,reason);

        return "审核成功";
    }


    @Override
    public PageUtils queryPageById(Map<String, Object> params, Integer gradeId) {
        IPage<DoctorMessageEntity> page = this.page(
                new Query<DoctorMessageEntity>().getPage(params)
        );
        String doctorName = (String) params.get("doctorName");
        List<DoctorMessageEntity> list=doctorMessageDao.findAllById(doctorName,gradeId);
        page.setRecords(list);
        return new PageUtils(page);
    }

}